package com.foreknow.demo6;

import java.io.FileInputStream;
import java.io.InputStream;

public class Master {
    public void cure(Pet pet){
       if (pet.getHealth()<50){
           pet.toHospital();
       }
    }
    public void play(Pet pet){
        if (pet instanceof Dog1){
            Dog1 dog1 = (Dog1)pet;
            dog1.catchingFly();
        }else if (pet instanceof Penguin){
            Penguin penguin = (Penguin)pet;
            penguin.swimming();
        }
    }

    public static void main(String[] args) {
        Master master = new Master();
        Dog1 dog1 = new Dog1();
        Penguin penguin = new Penguin();
        master.play(dog1);
        master.play(penguin);
        Pet p= new Dog1();
        p.setHealth(20);
        master.cure(p);
        p = new Penguin();
        p.setHealth(30);
        master.cure(p);
    }
}
